package com.jloading.ui;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import com.pope945.mypanel.BackGroundPane;
import com.pope945.mypanel.ComBrowserUrlPanel;
import com.pope945.popup.LastNewsWindows;
import com.util.ReadConfig;
import com.util.cmd.MyCMD;

import exchange4Server.Messager4Server;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JButton;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;

import org.jdesktop.application.Application;

import pope.jloading.JLoadingException;
import pope.jloading.TaskManager;
import pope.jloading.TaskModel;
import pope.jloading.TaskTableModel;
import pope.jloading.mycell.ColumnCellRenderer;
import pope.jloading.mycell.ProgressBarRenderer;
import pope.table.MusicModel;
import pope.table.MusicTableModel;
import softutil.UnInstall;

import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import com.util.ReadConfig;

import exchange4Server.Messager4Server;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Choose2DownloadPanelAdv extends javax.swing.JPanel implements Runnable ,TableModelListener {
	private BackGroundPane jPanel1;
	private BackGroundPane jPanel2;
	private JRadioButton jRadioButton2;
	private JRadioButton jRadioButton1;
	
	private javax.swing.JTable jTable1;
	private JScrollPane jScrollPane1;
	private JButton jButton1;
	private JButton jButton5;
	private JRadioButton jRadioButton4;
	private JRadioButton jRadioButton3;
	private JButton jButton2;
	private JButton jButton3;
	private JButton jButton4;
	
	private String downloadingUrl;
	private String sid="";
	

	private String path;
	
	private String action="";
	
	private String lastAction;	
	private JButton jp2_next;
	private JButton jp2_pre;
	private JButton jButton7;
	private JPanel jps;
	private CardLayout cardLayout;
	private BackGroundPane jPanel3;
	private BackGroundPane jPanel4;
	private Messager4Server m4s;
	private JButton jp3_uninstall;
	private JButton jp4_install;
	private JLabel jp4_serNum;
	private JLabel jp4_pro;
	private JLabel jp3_text;
	private JButton jp3_pre;
	private JButton jp3_next;
	private JButton jp4_pre;
	private String name;
	private Object progress;
	private JButton jb_del;
	private JButton jb_go_on;
	private JButton jb_pause;
	private BackGroundPane jp4_installtext;
	private BackGroundPane jp4_title;
	private BackGroundPane jp3_title;
	private JLabel jp2_title;
	private BackGroundPane jPanel5;
	private JPopupMenu popupMenu;
	private JMenuItem beginItem;
	private JMenuItem pauseItem;
	private JMenuItem stopItem;
	private JMenuItem deleteItem;
	private String str;
	private Thread proThread;


	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}	
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
//				frame.getContentPane().add(new Choose2DownloadPanelAdv());
				Choose2DownloadPanelAdv c2d=new Choose2DownloadPanelAdv();
				c2d.setAction("xiazai");
				frame.getContentPane().add(c2d);
				frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
				frame.pack();
				frame.setVisible(true);
			}
		});
	}
	/**
	 * 该构造函数为 不进行切换操作
	 *
	 */
	public Choose2DownloadPanelAdv() {
		super();		
		initGUI();		
	}
		
	/**
	 * 
	 * @param isChangeSerNum
	 */
	private void initGUI( ) {
		
		try {			
			{
				AnchorLayout thisLayout = new AnchorLayout();
					this.setLayout(thisLayout);
//					this.setSize(512, 352);
					this.setSize(new Dimension(486, 288));
				
					ButtonGroup buttonGroup1 = new ButtonGroup();
					
				{
					
					jps=new JPanel();//内容显示区域
					jps.setSize(486, 288);
					
					jPanel1 = new BackGroundPane();
					jPanel1.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/bg.jpg")));
					AnchorLayout jPanel1Layout = new AnchorLayout();
					jPanel1.setLayout(jPanel1Layout);
					jPanel1.setSize(486, 288);
					
					jps.add(jPanel1);
					
					jPanel1.setName("jPanel1");
					{
						jPanel5 = new BackGroundPane();
						jPanel1.add(jPanel5, new AnchorConstraint(1, 1001, 110, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
						jPanel5.setPreferredSize(new java.awt.Dimension(486, 40));
						jPanel5.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/titlebg.jpg")));
						{
							jp2_title = new JLabel();
							jPanel5.add(jp2_title);
							jp2_title.setName("jp2_title");
							jp2_title.setPreferredSize(new java.awt.Dimension(209, 27));
						}
					}
					

					String av1=ReadConfig.readValue("config.ini","name.antiv_0001");
					String av2=ReadConfig.readValue("config.ini","name.antiv_0002");
					String av3=ReadConfig.readValue("config.ini","name.antiv_0003");
					String av4=ReadConfig.readValue("config.ini","name.antiv_0004");
					
					
						jRadioButton1 = new JRadioButton(av1);
																		
						jPanel1.add(jRadioButton1, new AnchorConstraint(286, 463, 357, 81, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
						jRadioButton1.setName("jRadioButton1");
						jRadioButton1.setOpaque(false);
						jRadioButton1.setPreferredSize(new java.awt.Dimension(186, 26));
						
						jRadioButton2 = new JRadioButton(av2);
						jPanel1.add(jRadioButton2, new AnchorConstraint(286, 896, 357, 548, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
						jRadioButton2.setName("jRadioButton2");
						jRadioButton2.setOpaque(false);
						jRadioButton2.setPreferredSize(new java.awt.Dimension(169, 26));
						
						
						/*if(ispack80()){	//如果是80包月
						jRadioButton1.setEnabled(false);
						jRadioButton2.setEnabled(false);
												
						}*/
						
		    			jRadioButton3 = new JRadioButton(av3);
		    			jPanel1.add(jRadioButton3, new AnchorConstraint(554, 463, 634, 81, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
		    			jRadioButton3.setName("jRadioButton3");
		    			jRadioButton3.setPreferredSize(new java.awt.Dimension(186, 29));
		    			jRadioButton3.setOpaque(false);
		    			
		    			jRadioButton4 = new JRadioButton(av4);
		    			jPanel1.add(jRadioButton4, new AnchorConstraint(571, 896, 650, 548, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
		    			jRadioButton4.setName("jRadioButton4");
		    			jRadioButton4.setPreferredSize(new java.awt.Dimension(169, 29));
		    			jRadioButton4.setOpaque(false);
					
		    			jButton5 = new JButton();
	    				jPanel1.add(jButton5, new AnchorConstraint(842, 875, 935, 702, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
	    				jButton5.setName("jButton5");
	    				jButton5.setPreferredSize(new java.awt.Dimension(84, 27));
	    				jButton5.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/next1.jpg"))); 
	    				jButton5.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/next2.jpg")));
	    				
	    				
					
					//jPanel2
						jPanel2 = new BackGroundPane();
						jPanel2.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/2.jpg")));
						AnchorLayout jPanel2Layout = new AnchorLayout();
						jPanel2.setLayout(jPanel2Layout);
						jps.add(jPanel2);
						
						jPanel2.setName("jPanel2");
						{
							jb_del = new JButton();
							jPanel2.add(jb_del, new AnchorConstraint(848, 727, 942, 591, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jb_del.setPreferredSize(new java.awt.Dimension(66, 27));
							jb_del.setName("jb_del");
						}
						{
							jb_go_on = new JButton();
							jPanel2.add(jb_go_on, new AnchorConstraint(845, 566, 942, 426, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jb_go_on.setPreferredSize(new java.awt.Dimension(68, 28));
							jb_go_on.setName("jb_go_on");
						}
						{
							jb_pause = new JButton();
							jPanel2.add(jb_pause, new AnchorConstraint(842, 408, 942, 266, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jb_pause.setPreferredSize(new java.awt.Dimension(69, 29));
							jb_pause.setName("jb_pause");
						}
						{
							jp2_next = new JButton();
							jPanel2.add(jp2_next, new AnchorConstraint(852, 968, 942, 795, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jp2_next.setPreferredSize(new java.awt.Dimension(84, 26));
							jp2_next.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/next1.jpg"))); 
							jp2_next.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/next2.jpg")));
							
						}
						{
							jp2_pre = new JButton();
							jPanel2.add(jp2_pre, new AnchorConstraint(845, 196, 942, 12, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_ABS));
							jp2_pre.setPreferredSize(new java.awt.Dimension(83, 28));
							jp2_pre.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/pre1.jpg"))); 
							jp2_pre.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/pre2.jpg")));
							
						}
						
						jScrollPane1 = new javax.swing.JScrollPane();
						jPanel2.add(jScrollPane1, new AnchorConstraint(1, 995, 821, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
						jScrollPane1.setPreferredSize(new java.awt.Dimension(358, 310));
						jScrollPane1.setOpaque(false);
						
							jButton1 = new JButton("开始");
							jButton2 = new JButton("暂停");
							jButton3 = new JButton("停止");
							jButton4 = new JButton("删除");
							/*jPanel2.add(jButton1, new AnchorConstraint(833, 167, 907, 25, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jButton1.setPreferredSize(new java.awt.Dimension(69, 29));
							jPanel2.add(jButton2, new AnchorConstraint(833, 412, 907, 260, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jButton2.setPreferredSize(new java.awt.Dimension(74, 29));
							jPanel2.add(jButton3, new AnchorConstraint(836, 661, 904, 494, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jButton3.setPreferredSize(new java.awt.Dimension(81, 27));
							jPanel2.add(jButton4, new AnchorConstraint(833, 916, 909, 776, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jButton4.setPreferredSize(new java.awt.Dimension(68, 30));*/

							
							jTable1 = new javax.swing.JTable();
							jScrollPane1.setViewportView(jTable1);
							jScrollPane1.setOpaque(false);//透明
							this.jTable1.setRowHeight(22);
							jTable1.setModel( new TaskTableModel());//显示表头
							jTable1.setPreferredSize(new java.awt.Dimension(355, 267));
							jTable1.setOpaque(false); //表格透明
//							jTable1.setBackground(Color.black);
							
							// right click menu
							popupMenu=new  JPopupMenu();
							beginItem=new  JMenuItem("开始下载");
						    pauseItem=new  JMenuItem("暂停下载");
						    stopItem=new  JMenuItem("停止下载");
						    deleteItem=new JMenuItem("删除下载");
						   
						    popupMenu.add(beginItem);
						    popupMenu.add(pauseItem);
//						    popupMenu.add(stopItem);
						    popupMenu.add(deleteItem);
						
						    jTable1.getModel().addTableModelListener(this); //为什么 tableModelListener 变化了没有反映？
						    						    
						   
						    jTable1.addMouseListener(new MouseAdapter(){
					            @Override
					            public void mouseReleased(MouseEvent e) {
					                if (e.isPopupTrigger()) {
					                	popupMenu.show(e.getComponent(), e.getX(), e.getY());
					                    
					                }
					            }
					        });

						   
						    beginItem.addActionListener(new java.awt.event.ActionListener() {
			    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
			    	                jButton1ActionPerformed(evt);
			    	            }
			    	        });
						    pauseItem.addActionListener(new java.awt.event.ActionListener() {
			    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
			    	                jButton2ActionPerformed(evt);
			    	            }
			    	        });
						    stopItem.addActionListener(new java.awt.event.ActionListener() {
			    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
			    	                jButton3ActionPerformed(evt);
			    	            }
			    	        });
						    deleteItem.addActionListener(new java.awt.event.ActionListener() {
			    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
			    	                jButton4ActionPerformed(evt);
			    	            }
			    	        });
							
							
							
							//卸载软件
							jPanel3=new BackGroundPane();
							jPanel3.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/bg.jpg")));
							AnchorLayout jPanel3Layout = new AnchorLayout();
							jPanel3.setLayout(jPanel3Layout);
							{
								jp3_title =  new BackGroundPane();
								jPanel3.add(jp3_title, new AnchorConstraint(1, 1001, 242, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
								jp3_title.setPreferredSize(new java.awt.Dimension(486, 88));
								jp3_title.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/titlebg.jpg")));
								{
									jp3_text = new JLabel();
									jp3_title.add(jp3_text);
									jp3_text.setName("jp3_text");
									jp3_text.setPreferredSize(new java.awt.Dimension(395, 37));
								}
								{
									jp3_uninstall=new JButton();
									jp3_title.add(jp3_uninstall);
									jp3_uninstall.setPreferredSize(new java.awt.Dimension(83, 26));
									jp3_uninstall.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/uninstall1.jpg"))); 
									jp3_uninstall.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/uninstall2.jpg")));
									
								}
							}
							jp3_pre=new JButton();
							jp3_next=new JButton();//切换序列号
							jPanel3.add(jp3_pre, new AnchorConstraint(796, 293, 890, 120, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jp3_pre.setPreferredSize(new java.awt.Dimension(84, 27));
							jp3_pre.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/pre1.jpg"))); 
							jp3_pre.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/pre2.jpg")));
							
							jp3_next.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/next1.jpg"))); 
							jp3_next.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/next2.jpg")));
							
							jPanel3.add(jp3_next, new AnchorConstraint(796, 898, 890, 725, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jp3_next.setPreferredSize(new java.awt.Dimension(84, 27));

							//安装软件并 显示序列号
							jPanel4=new BackGroundPane();
							jPanel4.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/bg.jpg")));
							AnchorLayout jPanel4Layout = new AnchorLayout();
							jPanel4.setLayout(jPanel4Layout);
							{
								jp4_installtext = new BackGroundPane();
								jPanel4.add(jp4_installtext, new AnchorConstraint(554, 1001, 645, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
								jp4_installtext.setPreferredSize(new java.awt.Dimension(486, 33));
								jp4_installtext.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/titlebg.jpg")));
							}
							{
								jp4_title = new BackGroundPane();
								jPanel4.add(jp4_title, new AnchorConstraint(1, 1001, 102, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
								jp4_title.setPreferredSize(new java.awt.Dimension(486, 37));
								jp4_title.setImageIcon(new ImageIcon(this.getClass().getResource("/icon/step/titlebg.jpg")));
							}
							{
								jp4_serNum = new JLabel();
								jPanel4.add(jp4_serNum, new AnchorConstraint(349, 1001, 423, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
								jp4_serNum.setPreferredSize(new java.awt.Dimension(486, 27));
								jp4_serNum.setName("jp4_serNum");
								
							}
							{
								jp4_pro = new JLabel();
								jPanel4.add(jp4_pro, new AnchorConstraint(141, 737, 217, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
								jp4_pro.setPreferredSize(new java.awt.Dimension(358, 28));
								jp4_pro.setName("jp4_pro");

							}
							jp4_install=new JButton();
							jp4_pre=new JButton();
							jPanel4.add(jp4_pre, new AnchorConstraint(782, 293, 876, 120, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jp4_pre.setPreferredSize(new java.awt.Dimension(84, 27));
							jp4_pre.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/pre1.jpg"))); 
							jp4_pre.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/pre2.jpg")));
							jp4_pre.setName("jp4_pre");

							jPanel4.add(jp4_install, new AnchorConstraint(793, 854, 887, 684, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jp4_install.setPreferredSize(new java.awt.Dimension(83, 27));
							jp4_install.setIcon(new ImageIcon(this.getClass().getResource("/icon/step/install1.jpg"))); 
							jp4_install.setRolloverIcon(new ImageIcon(this.getClass().getResource("/icon/step/install2.jpg")));
							
							cardLayout = new CardLayout();
							jps.setLayout(cardLayout);//变化的panel
							System.out.println("this is action:"+action);
							if(this.getAction().equals("xiazai"))
					    		 cardLayout.show(jps, "jp2");
							
							jps.add("jp1",jPanel1);
							jPanel1.setPreferredSize(new java.awt.Dimension(486, 374));

							jps.add("jp2",jPanel2);
							jPanel2.setPreferredSize(new java.awt.Dimension(486, 346));
							jps.add("jp3",jPanel3);
							jps.add("jp4",jPanel4);
							jPanel4.setPreferredSize(new java.awt.Dimension(486, 288));

							this.add(jps, new AnchorConstraint(1, 1001, 1001, 1, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
							jps.setPreferredSize(new java.awt.Dimension(486, 394));

					}

					ActionListener a = new ActionListener() {
	    				public void actionPerformed(ActionEvent ae) {
	    					if (ae.getSource() ==jRadioButton1 ) {
	    						String urlstring=ReadConfig.readValue("config.ini","url.antiv_0001");	    						
								downloadingUrl=urlstring;
								sid="antiv_0001";
								if(action.equals("xiazai"))
									lastAction="xiazai";
								else lastAction="qiehuan";
	    					} else if(ae.getSource() ==jRadioButton2 ) {
	    						String urlstring=ReadConfig.readValue("config.ini","url.antiv_0002");	    						
								downloadingUrl=urlstring;
								sid="antiv_0002";
								if(action.equals("xiazai"))
									lastAction="xiazai";
								else lastAction="qiehuan";
	    					}else if(ae.getSource() ==jRadioButton3 ) {
	    						String urlstring=ReadConfig.readValue("config.ini","url.antiv_0003");	    						
								downloadingUrl=urlstring;
								sid="antiv_0003";
								if(action.equals("xiazai"))
									lastAction="xiazai";
								else lastAction="qiehuan";
	    					}else if(ae.getSource() ==jRadioButton4) {
	    						String urlstring=ReadConfig.readValue("config.ini","url.antiv_0004");	    						
								downloadingUrl=urlstring;
								sid="antiv_0004";
								if(action.equals("xiazai"))
									lastAction="xiazai";
								else lastAction="qiehuan";
	    					}else if(ae.getSource() ==jButton5) {	
	    						System.out.println("this is jbutton5 action");	    						
	    						if(action.equals("qiehuan")){//本次只存在切换情况
	    							  if(downloadingUrl!=null&&!(downloadingUrl.trim()).equals("")){//
	    								System.out.println("sssss downloadingUrl:"+downloadingUrl+" lastAction:"+lastAction+" sid:"+sid);	    							
//	    								if(	!checkNames(downloadingUrl))//不存在重名文件,存在config,不存在config
//	    									{	    								
//	    										confirm2Download(downloadingUrl,sid,lastAction);
////	    										cardLayout.next(jps);
//	    										cardLayout.show(jps, "jp2");
//	    										} else if(checkDoneNames(downloadingUrl)) //存在.exe 直接到下一步
//	    										{//存在相同文件
//	    											System.out.println(" :"+lastAction);	   	    										
//	    											m4s=new Messager4Server();
//	    											m4s.saveFile("info", "exitFileSid", sid);
//	    											System.out.println("存在相同文件 写入exitFileSid是 ："+sid);
//	    											
//	    											URL url;
//													try {
//														url = new URL(downloadingUrl);
//														String name_temp=getFileName(url);
//														name=name_temp;
//													} catch (MalformedURLException e) {									
//														e.printStackTrace();
//													}
//	    												
//	    											
//	    											showAlertNames(lastAction);	    //存在相同文件进行下一步操作		    											
//	    										}else if(checkConfigNames(downloadingUrl)) //存在_config文件
//	    										{	
//	    											showHasConfig();
//	    											cardLayout.show(jps, "jp2");
//	    									
//	    										}
	    								//TODO 如果存在 不存在EXE，不存在config ,但是存在临时文件
	    								
	    								if(checkDoneNames(downloadingUrl)) //存在.exe 直接到下一步
	    									{//存在相同文件
    											System.out.println(" :"+lastAction);	   	    										
    											m4s=new Messager4Server();
    											m4s.saveFile("info", "exitFileSid", sid);
    											System.out.println("存在相同文件 写入exitFileSid是 ："+sid);  											
    											URL url;
												try {
													url = new URL(downloadingUrl);
													String name_temp=getFileName(url);
													name=name_temp;
												} catch (MalformedURLException e) {									
													e.printStackTrace();
												}  												 											
    											showAlertNames(lastAction);	    //存在相同文件进行下一步操作		    											
    										}else{//不存在文件
    											if(checkConfigNames(downloadingUrl)){//不存在同名文件，但是存在config 
    												showHasConfig();
	    											cardLayout.show(jps, "jp2");
    											}else{
    												removeTempfile(downloadingUrl);
    												confirm2Download(downloadingUrl,sid,lastAction);
    											}
    											
    										}
	    								
							}else{
	    									   									
	    									showAlert(); //你没有选择产品的提示
	    									cardLayout.show(jps, "jp2");
//	    									name="";
	    									
	    								}
	    						  }else{	//    							  
	    							  	  cardLayout.next(jps);
		    							  if(downloadingUrl!=null&&!(downloadingUrl.trim()).equals("")){
		    							  confirm2Download(downloadingUrl,sid,lastAction);
		    							  
		    							  
		    						  }
	    						  }
	    						
	    						
	    						
	    						
	    						
	    					}else if(ae.getSource() ==jp2_pre) {
	    						cardLayout.previous(jps);	    						
	    					}else if(ae.getSource()==jp2_next){

	    						toNext();//
	    						
	    					}else if(ae.getSource()==jp3_pre){
	    						cardLayout.previous(jps);
	    					}else if(ae.getSource()==jp3_next){
	    						
	    						if(action.equals("qiehuan"))
	    							doChangeSerNum();
	    						else
	    							cardLayout.next(jps);
	    							
	    						
	    					}else if(ae.getSource()==jp3_uninstall){	    						
//									UnInstall.uninstall();
	    							new UnInstall().start();
								
	    					}else if(ae.getSource()==jp4_pre){
	    						cardLayout.previous(jps);
	    					}else if(ae.getSource()==jp4_install){
	    						System.out.println("jp4_install.name :"+name);//TODO name 需要传递过来
//	    						name=getNameFromUrl("");
	    						doInstallAction(name);
	    						
	    					}else if(ae.getSource()==jb_pause){
	    						pauseTasks();
	    					}else if(ae.getSource()==jb_go_on){
	    						startTasks();
	    					}else if(ae.getSource()==jb_del){
	    						deleteTasks();
	    					}
	    				}
	    			};
	    			
	    			
	    			

	    			buttonGroup1.add(jRadioButton1);
	    			
//	    			jRadioButton1.setPreferredSize(new java.awt.Dimension(163, 20));

	    			buttonGroup1.add(jRadioButton2);
	    			
//	    			jRadioButton2.setPreferredSize(new java.awt.Dimension(178, 20));
	    			buttonGroup1.add(jRadioButton3);
	    			buttonGroup1.add(jRadioButton4);
	    			
	    			if(!ispack80()){
	    			jRadioButton1.addActionListener(a);
	    			jRadioButton2.addActionListener(a);	  
	    			}
	    			jRadioButton3.addActionListener(a);	    				    			
	    			jRadioButton4.addActionListener(a);	 
	    			
	    			jButton5.addActionListener(a);
	    			jp2_pre.addActionListener(a);
	    			jp2_next.addActionListener(a);

	    			jp3_pre.addActionListener(a);
	    			jp3_next.addActionListener(a);
	    			jp3_uninstall.addActionListener(a);
	    			
	    			jp4_pre.addActionListener(a);
	    			jp4_install.addActionListener(a);
	    			
	    			
	    			jb_pause.addActionListener(a);
	    			jb_go_on.addActionListener(a);
	    			
	    			jb_del.addActionListener(a);
					
				}
			
					
			 // 设置任务管理
	        TaskManager tManager = TaskManager.getInstance();
	        tManager.setTable(jTable1);
	        tManager.loadTasks();

				 TableColumnModel tcm = jTable1.getColumnModel();
			        int columns = tcm.getColumnCount();
			        for (int i = 0; i < columns; i++) {
			            tcm.getColumn(i).setCellRenderer(new ColumnCellRenderer());
			        }
			        
			        TableColumn tc = tcm.getColumn(TaskModel.COLUMN_PROCESS);
			        tc.setCellRenderer(new ProgressBarRenderer());
			        
			       
			        
			        
			        jButton1.addActionListener(new java.awt.event.ActionListener() {
	    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
	    	                jButton1ActionPerformed(evt);
	    	            }
	    	        });
					jButton2.addActionListener(new java.awt.event.ActionListener() {
	    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
	    	                jButton2ActionPerformed(evt);
	    	            }
	    	        });
					jButton3.addActionListener(new java.awt.event.ActionListener() {
	    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
	    	                jButton3ActionPerformed(evt);
	    	            }
	    	        });
					jButton4.addActionListener(new java.awt.event.ActionListener() {
	    	            public void actionPerformed(java.awt.event.ActionEvent evt) {
	    	                jButton4ActionPerformed(evt);
	    	            }
	    	        });

					proThread = new Thread(this);
					proThread.start();
					
					
					
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	


protected void showHasConfig() {		
	JLabel jlb=new JLabel("已经存在该下载配置");	      
	JOptionPane.showMessageDialog(this, 
			jlb, "提示  ",JOptionPane.INFORMATION_MESSAGE);	
	}

/**
 * 通过URL 得到NAME
 * @param string
 * @return
 */
protected String getNameFromUrl(String string) {
		
		return null;
	}

protected void doChangeSerNum() {	
	
	
	if(jTable1.getSelectedRow()>-1)
	{
		String name =jTable1.getValueAt(jTable1.getSelectedRow(),1).toString();//name
		String antiv_0001=ReadConfig.readValue("config.ini", "url.antiv_0001");
		String antiv_0002=ReadConfig.readValue("config.ini", "url.antiv_0002");
		String antiv_0003=ReadConfig.readValue("config.ini", "url.antiv_0003");
		String antiv_0004=ReadConfig.readValue("config.ini", "url.antiv_0004");
		
		String name_antiv_0001=m4s.getName(antiv_0001);
		String name_antiv_0002=m4s.getName(antiv_0002);
		String name_antiv_0003=m4s.getName(antiv_0003);
		String name_antiv_0004=m4s.getName(antiv_0004);
		if(name.equals(name_antiv_0001)){
			sid="antiv_0001";
		}else if(name.equals(name_antiv_0002)){
			sid="antiv_0002";
		}else if(name.equals(name_antiv_0003)){
			sid="antiv_0003";
		}else if(name.equals(name_antiv_0004)){
			sid="antiv_0004";
		}
		
	}
	
	
	

	if(action.equals("qiehuan")){
		
		cardLayout.last(jps);
		try {
			
			m4s.changeSerNum2LocalFile(sid);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	else 
		cardLayout.last(jps);
	}

/**
 * 进行安装操作 
 *
 */
	protected void doInstallAction(String name) {
//		System.out.println("doInstallAction :"+name);
		
		File mypath = new File("idownloads");
        String path=mypath.getAbsolutePath();			        
        MyCMD.exeCMD(path, name);
//        System.out.println("this is path :"+path);
		
	}

	/**
	 * 选种表格中一行然后 进行下一步，如果不选种就提示
	 *
	 */
	protected void toNext() {
		 TaskManager tManager = TaskManager.getInstance();
	        int[] keys = jTable1.getSelectedRows();
	        
//	        System.out.println("keys"+keys.length);
	        if (keys.length==1){
	        	if(action.equals("qiehuan"))
	        	cardLayout.next(jps); 
	        	else{
	        		cardLayout.next(jps);
	        		action="xiazai";
	        	}
	        	 name=(String) jTable1.getValueAt(jTable1.getSelectedRow(),1);
//	        	 sid="";
//	        	 setSidFromName(name);
	        	 progress =jTable1.getValueAt(jTable1.getSelectedRow(),2);//TODO 进度条修改
	        	System.out.println("progress:"+progress);
	        	if(!progress.equals(100)){        		
	        		JLabel jlb=new JLabel("下载没有完成");	      
		        	JOptionPane.showMessageDialog(this, jlb, "下载没有完成",JOptionPane.INFORMATION_MESSAGE);
	        	}
	        	
	        	
	        }else {
	        	JLabel jlb=new JLabel("你先选中要操作的一行");	      
	        	JOptionPane.showMessageDialog(this, jlb, "你没有选中要操作",JOptionPane.INFORMATION_MESSAGE);
	       
	        }	
		
	}

//	private void setSidFromName(String name2) {
//		if(name.equals(""))
//			sid=
//		
//	}

	private boolean ispack80() throws Exception {
		 m4s=new Messager4Server();
		 String clientInfo=m4s.getClientInfoString();
//		 System.out.println(" clientInfo :"+clientInfo);
		 if(clientInfo!=null&&!clientInfo.equals("")){
			 String temp=clientInfo.split("\\$")[2];
//			 System.out.println("pid:"+temp);
			 if(temp.equals("pack80"))
				 return true;
			 else
				 return false;
		 }else{
			 return false;
			 }
		}

	protected void showAlert() {
		JLabel jlb=new JLabel("<html> <a href=''>你没有选择产品</a> <br>  </html>");	      
		JOptionPane.showMessageDialog(this, 
				jlb, "提示  ",JOptionPane.INFORMATION_MESSAGE);
		
	}
	
	/**
	 * showAlert about has double name
	 */
	protected void showAlertNames(String action) {
		/*int option = JOptionPane.showConfirmDialog(null, "已经存在该下载文件，是否进行下一步操作", "提示",JOptionPane.YES_NO_OPTION);
		if (option == JOptionPane.YES_OPTION){
			System.out.println("这里执行下一步操作");											
		} else {
			System.out.println("不动作");
			
		}*/
		
		JLabel jlb=new JLabel("<html> <a href=''>已经存在下载文件，进行下一步操作</a> <br>  </html>");	      
		JOptionPane.showMessageDialog(this, jlb, "提示 ",JOptionPane.INFORMATION_MESSAGE);
		 
		String path1 = downloadingUrl.substring(downloadingUrl.lastIndexOf("/")).trim();
    	String name1=path1.substring(1);    
    	
    	 m4s=new Messager4Server();
    		try {
    			cardLayout.show(jps, "jp3");
				String sid=m4s.readFile("info", "exitFileSid");
				System.out.println("存在文件 切换的 sid:"+sid);
				name=name1;
				//安装文件 需要传递 name 
//			UnInstall.confirm2Uninstall(name,action,sid);
				
				//TODO 切换序列号
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
							
	}

	
	
	/**
	 * 确定按钮事件
	 * @param downloadingUrl
	 */
	protected void confirm2Download(String downloadingUrl,String sid,String action) {
		try {			
			URL url;
			try {
				url = new URL(downloadingUrl);
				String name=getFileName(url);
				
//				addTasks(name,downloadingUrl,sid,action);	// addtask 后，表格改变，触发事件改变
				addTaskSid(name,downloadingUrl,sid,action);
				Messager4Server m4s=new Messager4Server();
				m4s.saveFile("info", "2changeSid",sid);

//				new StartTaskIn5sec().start();//开始下载
//				startTaskLast();
			
				
			} catch (MalformedURLException e) {										
				e.printStackTrace();
			}    							
			
		} catch (JLoadingException e) {							
			e.printStackTrace();
		}
		
	}

	/**
	 * 
	 * @author after  n seconds to 从最后一行开始下载
	 *
	 */
	private  class StartTaskIn5sec extends Thread {   	
	    	 public void run() {
				try {
					Thread.sleep(2000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				
//				startTasksAll();//全部开始
				startTaskLast();//最后一行开始
			}

	    	 /**
	    	  * 将最后加入的自动下载
	    	  *
	    	  */
			  
	    }
		
	
	private void startTaskLast() {
		TaskManager tManager = TaskManager.getInstance();
        int rows = jTable1.getRowCount();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
//        for (int row=0;row<rows;row++) {
            tManager.startTask(ttm.getTask(rows-1));
//        }
	}  
		
		/**
		 * 
		 * @param url
		 * @return
		 */

	protected String getFileName(URL url) {
		
		String fileName = url.getFile();
		//在此对象表示的字符序列中最后一次出现该字符的索引，如果未出现该字符，则返回 -1
		return fileName.substring(fileName.lastIndexOf('/') + 1);	
	}
	
	protected void jButton4ActionPerformed(ActionEvent evt) {
		deleteTasks();		
	}

	protected void jButton3ActionPerformed(ActionEvent evt) {
		stopTasks();		
	}

	protected void jButton2ActionPerformed(ActionEvent evt) {
		pauseTasks();		
	}

	protected void jButton1ActionPerformed(ActionEvent evt) {
		startTasks();		
	}
	
	private void startTasks() {
        TaskManager tManager = TaskManager.getInstance();
//        tManager.setTable(jTable1);// THIS IS ADD BY POPE
        int[] keys = jTable1.getSelectedRows();//TODO 为什么JTable why no action
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int key : keys) {
            tManager.startTask(ttm.getTask(key));
        }
    }
    

    private void pauseTasks() {
        TaskManager tManager = TaskManager.getInstance();
        int[] keys = jTable1.getSelectedRows();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int key : keys) {
            tManager.pauseTask(ttm.getTask(key));
        }
    }
    
    private void stopTasks() {
        TaskManager tManager = TaskManager.getInstance();
        int[] keys = jTable1.getSelectedRows();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int key : keys) {
            tManager.stopTask(ttm.getTask(key));
        }
    }
    
    private void deleteTasks() {
        ArrayList<TaskModel> taskToDel = new ArrayList<TaskModel>();
        int[] keys = jTable1.getSelectedRows();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int i = 0; i < keys.length; i++) {
            int k = keys[i];
            taskToDel.add(ttm.getTask(k));
        }
        TaskManager tManager = TaskManager.getInstance();
        tManager.deleteTasks(taskToDel);
    }

	/**
     * 添加任务
     */
    private void addTasks() throws JLoadingException {
        TaskManager tManager = TaskManager.getInstance();
        TableModel tableModel = jTable1.getModel();
        int[] keys = jTable1.getSelectedRows();
        if (tableModel instanceof MusicTableModel) {//上面表的内容
            MusicTableModel mtm = (MusicTableModel) tableModel;
            List<MusicModel> musics = mtm.getValues();
            
            for (int key : keys) {
                MusicModel mm = musics.get(key);
                tManager.addTask(mm.getName(), mm.getUrl());
            }
        }
    }
    
    private void addTasks(String name,String url,String sid,String action) throws JLoadingException {
        TaskManager tManager = TaskManager.getInstance();
        TableModel tableModel = jTable1.getModel();
        int[] keys = jTable1.getSelectedRows();
//        if (tableModel instanceof MusicTableModel) {
//            MusicTableModel mtm = (MusicTableModel) tableModel;
//            List<MusicModel> musics = mtm.getValues();
            
            for (int i=0;i<1;i++) {
                tManager.addTaskSid(name, url,sid,action);
                
            }
//            startTasks();
            
//        }
    }
    
    /**
     * 增加一条记录
     */
    private void addTaskSid(String name,String url,String sid,String action) throws JLoadingException {
        TaskManager tManager = TaskManager.getInstance();
//        TableModel tableModel = jTable1.getModel();
                tManager.addTaskSid(name, url,sid,action);
                

    }
    

    
    /**
     * 开始所有任务
     */
    private void startTasksAll() {
        TaskManager tManager = TaskManager.getInstance();
//        tManager.setTable(jTable1);// THIS IS ADD BY POPE
        int rows = jTable1.getRowCount();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int row=0;row<rows;row++) {
            tManager.startTask(ttm.getTask(row));
        }
    }
    
    private void pauseTasksAll() {
        TaskManager tManager = TaskManager.getInstance();
        int rows = jTable1.getRowCount();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int row=0;row<rows;row++) {
            tManager.pauseTask(ttm.getTask(row));
        }
    }
    
    private  boolean checkNames(String url) {            	
        	String path1 = url.substring(url.lastIndexOf("/")).trim();
        	String name=path1.substring(1);       
            
                File musics = new File("idownloads");
                if (!musics.exists()) {
                    musics.mkdirs();
                }      
            path = musics.getAbsolutePath();
              
          
             
            path=path+"\\"+name;
             System.out.println("checkName_path:"+path);
             
                String f_head = path.substring(0, path.lastIndexOf("."));
                String f_suffix = path.substring(path.lastIndexOf(".")); // 含"."
                File f1 = new File(path);               // 最终保存文件
                File f2 = new File(path + "_");         // 未完成任务之前的文件名
                File f3 = new File(path + "_config");   // 状态保存文件
                // 检查并确保不存在相同名称的文件名，saveChange标识（存在相同的文件名)
                System.out.print(" f_head "+f_head +"1 :"+f1.exists()+" 2:"+f2.exists()+ " 3:"+f3.exists());
//               if(f1.exists() || f2.exists() || f3.exists()) {
                
                if(f1.exists()||f3.exists() ) { //有一个漏洞，不能多个文件下载，不然会有问题
            	                 	
                	/*int option = JOptionPane.showConfirmDialog(null, "你存在下载文件，是否进行切换序列号", "提示",JOptionPane.YES_NO_OPTION);
    				if (option == JOptionPane.YES_OPTION){
    					System.out.println("this is OK Action");
    				}else{
    					
    				}*/
    				return true;
                	
                }else{
                	return false;
                }          
           
    }
    
    /**
     * 检查存在已经完成的文件 
     */
    private  boolean checkDoneNames(String url) {            	
    	String path1 = url.substring(url.lastIndexOf("/")).trim();
    	String name=path1.substring(1);       
        
            File musics = new File("idownloads");
            if (!musics.exists()) {
                musics.mkdirs();
            }      
        path = musics.getAbsolutePath();
       
        path=path+"\\"+name;
         System.out.println("checkName_path:"+path);
         
            String f_head = path.substring(0, path.lastIndexOf("."));
            String f_suffix = path.substring(path.lastIndexOf(".")); // 含"."
            File f1 = new File(path);               // 最终保存文件
            File f2 = new File(path + "_");         // 未完成任务之前的文件名
            File f3 = new File(path + "_config");   // 状态保存文件
            // 检查并确保不存在相同名称的文件名，saveChange标识（存在相同的文件名)
            
            if(f1.exists() ) { //有一个漏洞，不能多个文件下载，不然会有问题
				return true;
				
            }else{
            	return false;
            }          
       
}
    
    
    /**
     * 检查存在有配置文件的文件
     */
    private  boolean checkConfigNames(String url) {            	
    	String path1 = url.substring(url.lastIndexOf("/")).trim();
    	String name=path1.substring(1);       
        
            File musics = new File("idownloads");
            if (!musics.exists()) {
                musics.mkdirs();
            }      
        path = musics.getAbsolutePath();
       
        path=path+"\\"+name;
         System.out.println("checkName_path:"+path);
         
            String f_head = path.substring(0, path.lastIndexOf("."));
            String f_suffix = path.substring(path.lastIndexOf(".")); // 含"."
            File f1 = new File(path);               // 最终保存文件
            File f2 = new File(path + "_");         // 未完成任务之前的文件名
            File f3 = new File(path + "_config");   // 状态保存文件
            // 检查并确保不存在相同名称的文件名，saveChange标识（存在相同的文件名)
            
            if(f3.exists() ) { 
				return true;            	
            }else{
            	return false;
            }               
}
    
    /**
     * 检查存在有配置文件的文件
     */
    private void removeTempfile(String url) {            	
    	String path1 = url.substring(url.lastIndexOf("/")).trim();
    	String name=path1.substring(1);       
        
            File musics = new File("idownloads");
            if (!musics.exists()) {
                musics.mkdirs();
            }      
        path = musics.getAbsolutePath();
       
        path=path+"\\"+name;
         System.out.println("checkName_path:"+path);
         
            String f_head = path.substring(0, path.lastIndexOf("."));
            String f_suffix = path.substring(path.lastIndexOf(".")); // 含"."
            File f1 = new File(path);               // 最终保存文件
            File f2 = new File(path + "_");         // 未完成任务之前的文件名
            File f3 = new File(path + "_config");   // 状态保存文件
            // 检查并确保不存在相同名称的文件名，saveChange标识（存在相同的文件名)
            
            if(f2.exists() ) { 
				f2.delete();           	
            }              
}
    
    
	public void run() {//读文件 更新
		while (true) {
			try {
				if(ispack80()){	//如果是80包月
				jRadioButton1.setEnabled(false);
				jRadioButton2.setEnabled(false);									
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			
			if(sid.equals("antiv_0001")){
				jp4_pro.setText("切换的产品是：趋势科技防病毒软件");
				
			}else if (sid.equals("antiv_0002")){
				jp4_pro.setText("切换的产品是：江民防病毒软件");	
				
			}else if (sid.equals("antiv_0003")){
				jp4_pro.setText("切换的产品是：卡巴斯基防病毒软件");	
				
			}else if (sid.equals("antiv_0004")){
				jp4_pro.setText("切换的产品是：瑞星防病毒软件");	
				
			}else{
				 if(action.equals("qiehuan"))
					 jp4_pro.setText("你没有正确选择要切换的产品");	
				 else
					 jp4_pro.setText("你选择的是下载操作");
					 
			}
			
//			System.out.println("test action : "+action);
			if (action.equals("xiazai")){
				try {
				String temp=m4s.readFile("info", "serNum_order");
					jp4_serNum.setText("原来订购序列号："+temp);
				} catch (IOException e) {
					
					e.printStackTrace();
				}
			}else if (action.equals("qiehuan")){
				try {
					String temp=m4s.readFile("info", "serNum_change");
						jp4_serNum.setText("切换的序列号："+temp);
					} catch (IOException e) {
						
						e.printStackTrace();
					}
			}
			
//			jp4_pro.setText("Now   Time   Is:   " + datetime);
					
			try {
				Thread.sleep(9000);
			} catch (Exception e) {
			}
		}
	}

	public void tableChanged(TableModelEvent e) {
		cardLayout.show(jps, "jp2");		
		//最后一行开始下载其他暂停 
//		startEndAndStopOther();		会报错
//		System.out.println("这个事件被触发了");	
//		startTaskLast();
		new StartTaskIn5sec().start();
	}

	private void startEndAndStopOther() {
		TaskManager tManager = TaskManager.getInstance();
        int rows = jTable1.getRowCount();
        TaskTableModel ttm = (TaskTableModel) jTable1.getModel();
        for (int row=0;row<rows-1;row++) {
        	tManager.stopTask(ttm.getTask(row));
		
        }
        tManager.startTask(ttm.getTask(rows-1));//最后一行开始
	}
    
}
